#pragma once

#include "UMLDiagramWithAssociations.h"


namespace uml {

const bool UMLDiagramWithAssociations::isAssociationDotShown_default_ = false;
UMLDiagramWithAssociations::UMLDiagramWithAssociations(const QString& umlType)
    : UMLDiagram(umlType) {}

void UMLDiagramWithAssociations::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLDiagram::fromJson(json, errorList);
    isAssociationDotShown_ = json.value("isAssociationDotShown").toBool(isAssociationDotShown_default_);
    navigabilityNotation_ = (UMLNavigabilityNotationKind)json.value("navigabilityNotation").toInt((int)navigabilityNotation_);
    nonNavigabilityNotation_ = (UMLNavigabilityNotationKind)json.value("nonNavigabilityNotation").toInt((int)nonNavigabilityNotation_);
}

void UMLDiagramWithAssociations::toJson(QJsonObject& json) {
    UMLDiagram::toJson(json);
    if (isAssociationDotShown_ != isAssociationDotShown_default_) {
        json.insert("isAssociationDotShown", isAssociationDotShown_);
    }
    json.insert("navigabilityNotation", (int)navigabilityNotation_);
    json.insert("nonNavigabilityNotation", (int)nonNavigabilityNotation_);
}

/// <summary>
/// isAssociationDotShown getter
/// Indicates whether dot notation for associations shall be used.
/// </summary>
bool UMLDiagramWithAssociations::isAssociationDotShown() const {
    return isAssociationDotShown_;
}

/// <summary>
/// isAssociationDotShown setter
/// Indicates whether dot notation for associations shall be used.
/// </summary>
void UMLDiagramWithAssociations::setIsAssociationDotShown(bool value) {
    isAssociationDotShown_ = value;
}

/// <summary>
/// navigabilityNotation getter
/// Indicates when to show navigability of associations or connectors typed by
/// associations.
/// </summary>
UMLNavigabilityNotationKind UMLDiagramWithAssociations::navigabilityNotation() const {
    return navigabilityNotation_;
}

/// <summary>
/// navigabilityNotation setter
/// Indicates when to show navigability of associations or connectors typed by
/// associations.
/// </summary>
void UMLDiagramWithAssociations::setNavigabilityNotation(UMLNavigabilityNotationKind value) {
    navigabilityNotation_ = value;
}

/// <summary>
/// nonNavigabilityNotation getter
/// Indicates when to show non-navigability of associations or connectors typed by
/// associations.
/// </summary>
UMLNavigabilityNotationKind UMLDiagramWithAssociations::nonNavigabilityNotation() const {
    return nonNavigabilityNotation_;
}

/// <summary>
/// nonNavigabilityNotation setter
/// Indicates when to show non-navigability of associations or connectors typed by
/// associations.
/// </summary>
void UMLDiagramWithAssociations::setNonNavigabilityNotation(UMLNavigabilityNotationKind value) {
    nonNavigabilityNotation_ = value;
}

} // namespace uml
